package com.jfinal.j2cache.impl.ehcache;

import com.jfinal.j2cache.CacheManager;
import com.jfinal.plugin.ehcache.CacheKit;

public class EhcacheManager implements CacheManager {
    @Override
    public <T> T get(String cacheName, String key) {
        Object object = CacheKit.get(cacheName, key);
        if (null != object) {
            return (T) object;
        }
        return null;
    }

    @Override
    public void put(String cacheName, String key, Object value) {
        CacheKit.put(cacheName, key, value);
    }

    @Override
    public void evict(String cacheName, String key) {
        CacheKit.remove(cacheName, key);
    }

    @Override
    public void clear(String cacheName) {
        CacheKit.removeAll(cacheName);
    }
}
